const express = require("express");
const bannerService = require("../service/bannerService");
const bannerRouter = express.Router();
const formatResponse = require("../utils/responseFormat");

//获取首页图片/标语
bannerRouter.get("/", async (req, res, next) => {
  const data = await bannerService.getBannerInfo();
  res.send(formatResponse(0, "", data));
});

//修改首页信息
bannerRouter.put("/", async (req, res, next) => {
  const data = await bannerService.setBannerInfo(req.body);
  res.send(formatResponse(0, "", data));
});

//添加首页信息
bannerRouter.post("/", async (req, res) => {
  const data = await bannerService.addBannerInfo(req.body);
  res.send(formatResponse(0, "", data));
});

module.exports = bannerRouter;
